﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Data;

namespace CMD.BAL.CAT
{
    [DataContractAttribute]
    public class Iva
    {
        [DataMemberAttribute(EmitDefaultValue = false)]
        public string dscIva;
        [DataMemberAttribute(EmitDefaultValue = false)]
        public string ivaVal;
        public static DataTable GetData(int idZona)
        {
            DataTable dt;
            //ejecutar store
            dt = CMD_WEB.DAL.SrvDB.ExecuteQuery("exec SP_CMD_GET_SOL_IVA'" + idZona + "'");
            return dt;
        }
        public static Iva GetDataIva(int idZona)
        {
            try
            {
                Iva iv;
                DataTable dt = Iva.GetData(idZona);
                if (dt.Rows.Count == 0)
                {
                    return null;
                }
                else if (idZona == 0)
                {
                    return null;
                }
                else
                {
                    iv = new Iva(Convert.ToString(dt.Rows[0]["DSC_IVA"]), Convert.ToString(dt.Rows[0]["IVA_VAL"]));
                }
                return iv;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public Iva()
        {
            dscIva = "";
            ivaVal = "";
        }
        public Iva(string dscIva, string ivaVal)
        {
            this.dscIva=dscIva;
            this.ivaVal=ivaVal;
        }
    }
}
